package cn.com.connext.scrm.config;

import org.csource.fastdfs.FastDFSClient;
import org.csource.fastdfs.FastDFSProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties({FastDFSProperties.class})
public class FastDFSAutoConfiguration {

  private final Logger log = LoggerFactory.getLogger(FastDFSAutoConfiguration.class);

  @Autowired
  FastDFSProperties env;

  @Bean
  @ConditionalOnProperty("fastdfs.enabled")
  public FastDFSClient buildFastDFSClient() {
    log.debug("Configuring FastDFSClient");
    return new FastDFSClient(env);
  }

}
